package com.dubbo.user.facade;

import com.dubbo.user.api.IUserFacade;
import com.dubbo.user.dto.request.UserAddRequest;
import com.dubbo.user.dto.response.UserAddResponse;
import com.dubbo.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * @author dongdingzhuo
 * @description dubbo用户服务实现
 */
@DubboService(version = "1.0.1")
@Slf4j
public class UserFacade implements IUserFacade {

    @Resource
    private UserService userService;

    /**
     * 添加用户
     *
     * @param request
     * @return
     */
    @Override
    public UserAddResponse userAdd(UserAddRequest request) {
        if ("admin".equals(request.getUsername())) {
            return UserAddResponse.builder()
                    .username(request.getUsername())
                    .build();
        }
        log.info("进来了:{}", request.getUsername());
        return userService.userAdd(request);
    }
}
